package com.gitee.utils;

import java.util.regex.Pattern;

/**
 * 字符串工具类
 * 
 * @author 赵炎
 * @version [V1.00, 2017年10月30日]
 * @see [相关类/方法]
 * @since V1.00
 */
public class StringUtils
{
    public static final String SPACE = " ";
    
    public static final String EMPTY = "";
    
    public static final String LF = "\n";
    
    public static final String CR = "\r";
    
    /**
     * index not found
     */
    public static final int INDEX_NOT_FOUND = -1;
    
    public static final Pattern WHITESPACE_PATTERN = Pattern.compile("(?: |\\\\u00A0|\\\\s|[\\\\s&&[^ ]])\\\\s*");
    
    public StringUtils()
    {
        super();
    }
    
    public static boolean isEmpty(final CharSequence cs)
    {
        return cs == null || cs.length() == 0;
    }
    
    public static boolean isNotEmpty(final CharSequence cs)
    {
        return !isEmpty(cs);
    }
    
    public static boolean isBlank(final CharSequence cs)
    {
        int strLen;
        if (cs == null || (strLen = cs.length()) == 0)
        {
            return true;
        }
        for (int i = 0; i < strLen; i++)
        {
            if (Character.isWhitespace(cs.charAt(i)) == false)
            {
                return false;
            }
        }
        return true;
    }
    
    public static boolean isNotBlank(final CharSequence cs)
    {
        return !isBlank(cs);
    }
    
}
